package cn.edu.scau.cmi.chenyiqiu.experience.client;

import cn.edu.scau.cmi.chenyiqiu.client.AbstractFactoryClient;
import cn.edu.scau.cmi.chenyiqiu.client.ClassAdapterClient;
import cn.edu.scau.cmi.chenyiqiu.client.CompositeClient;
import cn.edu.scau.cmi.chenyiqiu.client.ObjectAdapterClient;
import cn.edu.scau.cmi.chenyiqiu.client.SimpleFactoryMethodClient;
import cn.edu.scau.cmi.chenyiqiu.client.SingletonClient;
import javafx.fxml.FXML;
import javafx.scene.control.Alert;
import javafx.scene.control.Button;
import javafx.scene.control.Alert.AlertType;
import javafx.stage.Stage;

public class Controller {
	@FXML
	private Button button1 = new Button("实验一");
	@FXML
	private Button button2 = new Button("实验二单例模式");
	@FXML
	private Button button3 = new Button("实验三工厂模式");
	@FXML
	private Button button4 = new Button("实验四类适配器模式");
	@FXML
	private Button button5 = new Button("实验四对象适配器模式");
	@FXML
	private Button button6 = new Button("实验五组合模式");
	@FXML
	private Button button7 = new Button("实验六Hibernate框架");
	@FXML
	private Button button8 = new Button("实验七IOC、DI模式");
	
	public void setAction() {
		button1.setOnAction(e->{
			try {
				new AbstractFactoryClient().start(new Stage());
			}catch(Exception c) {
				
			}
			;
		});
		
		button2.setOnAction(e->{
			try {
				new SingletonClient().start(new Stage());
			}catch(Exception c) {
				
			}
			;
		});
		button3.setOnAction(e->{
			try {
				new SimpleFactoryMethodClient().start(new Stage());
			}catch(Exception c) {
				
			}
			;
		});
		
		button4.setOnAction(e->{
			try {
				new ClassAdapterClient().start(new Stage());
			}catch(Exception c) {
				
			}
			;
		});
		
		button5.setOnAction(e->{
			try {
				new ObjectAdapterClient().start(new Stage());
			}catch(Exception c) {
				
			}
			;
		});
		button6.setOnAction(e->{
			try {
				new CompositeClient().start(new Stage());
			}catch(Exception c) {
				
			}
			;
		});
		
		button7.setOnAction(e->{
			try {
				 Alert alert = new Alert(AlertType.INFORMATION);
		            alert.titleProperty().set("信息");
		            alert.headerTextProperty().set("请看Console窗口");
		            alert.showAndWait();
		            HibernateThread t1=new HibernateThread();
		            t1.start();
			}catch(Exception c) {
				
			}
			;
		});
		button8.setOnAction(e->{
			try {
				Alert alert = new Alert(AlertType.INFORMATION);
	            alert.titleProperty().set("信息");
	            alert.headerTextProperty().set("请看Console窗口");
	            alert.showAndWait();
				SpringThread t2=new SpringThread();
				t2.start();
			}catch(Exception c) {
				
			}
			;
		});

	}
}
